﻿using UnityEngine;
public class HexCellPoint
{
    public Vector2Int Coordinate;
    public HexCellPoint Parent;
    /// <summary>
    /// 离起点的距离
    /// </summary>
    public int G;
    /// <summary>
    /// 离终点的距离
    /// </summary>
    public int H; 
    /// <summary>
    /// 计算当前点到起点的距离
    /// </summary>
    public void CaculateG()
    {
        G = Parent != null ? Parent.G + 1 : 0; //对于六边形地图来说，只加1就可以了
    }
    public int F { get { return G + H; } }
    public static bool Compare(HexCellPoint p1, HexCellPoint p2)
    {
        int p1f = p1.F, p2f = p2.F;
        if (p1f == p2f)
            return p1.H < p2.H;
        return p1f < p2f;
    }
}